<?php
namespace App\Http\Controllers\User;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\DB;
use App\Models\NewModel;

class NewsController extends Controller{

    public function __construct()
    {
        $this->middleware('user_login');
    }

    //获取新闻列表
    public function news(NewModel $newModel){

        $data = $newModel
            ->select([
                'id',
                'title',
                'sub_title',
                'created_at',
            ])
            ->paginate(15);
        return returnMsg(0,'获取成功',$data);

    }

    //获取新闻列表
    public function news_info(Request $request,NewModel $newModel){

        $data = $newModel->where('id',$request->input('news_id'))->first();
        return returnMsg(0,'获取成功',$data);
    }

}